// 判断是否是微信浏览器的函数
export function isWeiXin() {
  return false;
  // if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {//判断是否是移动设备打开。browser代码在下面
  //   let ua = navigator.userAgent.toLowerCase();//获取判断用的对象
  //   if (ua.match(/MicroMessenger/i) == "micromessenger") {
  //     return true
  //   }else{
  //     return false
  //   }
  // }else{
  //   return false
  // }
}
// 将秒数转化为时分秒
export function formatSeconds(value) {
  let theTime = parseInt(value); // 秒
  let theTime1 = 0; // 分
  let theTime2 = 0; // 小时
  if (theTime > 60) {
    theTime1 = parseInt(theTime / 60);
    theTime = parseInt(theTime % 60);
    if (theTime1 > 60) {
      theTime2 = parseInt(theTime1 / 60);
      theTime1 = parseInt(theTime1 % 60);
    }
  }
  let result = `${parseInt(theTime)}`;
  if (result < 10) {
    result = `0${result}`;
  }
  if (theTime1 > 0) {
    result = `${parseInt(theTime1)}:${result}`;
    if (theTime1 < 10) {
      result = `0${result}`;
    }
  } else {
    result = `00:${result}`;
  }
  if (theTime2 > 0) {
    result = `${parseInt(theTime2)}:${result}`;
    if (theTime2 < 10) {
      result = `0${result}`;
    }
  } else {
    result = `00:${result}`;
  }
  return result;
}
// 日期格式化函数
export function dateFormat(date, format) {
  const o = {
    "M+": date.getMonth() + 1, // month
    "d+": date.getDate(), // day
    "h+": date.getHours(), // hour
    "m+": date.getMinutes(), // minute
    "s+": date.getSeconds(), // second
    "q+": Math.floor((date.getMonth() + 3) / 3), // quarter
    S: date.getMilliseconds(), // millisecond
  };
  if (/(y+)/.test(format)) {
    format = format.replace(RegExp.$1, `${date.getFullYear()}`.substr(4 - RegExp.$1.length));
  }
  for (const k in o) {
    if (new RegExp(`(${k})`).test(format)) {
      format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : `00${o[k]}`.substr(`${o[k]}`.length));
    }
  }
  return format;
}
